<?php


/** @see Zend_Controller_Action */
require_once 'Zend/Controller/Action.php';

/**
 * Controleur d'action principal
 */
class HtmlController extends Zend_Controller_Action
{

    /**
     * Simple use of datagrid
     */
    public function indexAction()
    {
        //include path
        set_include_path(
            APP_BASE_PATH . '/application/data'
            . PATH_SEPARATOR
            . APP_BASE_PATH . '/application/models'
            . PATH_SEPARATOR
            . get_include_path()
        );

        //or use Zend_Config object
        $config = new Zend_Config_Ini('datagrid.ini');

        //creating the datagrid object
        $grid = new Zend_DataGrid($config);
        $grid->setDatasource($this->getDatasource());

        //personnalize the htm renderers
        //$grid->setOption('attributes', (array('border'=>'0', 'cellspacing'=>'0', 'cellpadding'=>'0', 'bgcolor'=>'#E8E3FB')));
        $grid->setAttributes(array('border'=>'0', 'cellspacing'=>'0', 'cellpadding'=>'0', 'bgcolor'=>'#E8E3FB'));
        $grid->setshowHeader(true)
             ->setShowFooter(true)
             ->setAttribute('width', '400px')
             ->setAttribute('onclick', "alert('You call me?')")
             ->setOption('showPager', true)
             ->setHeaderAttributes(array('bgcolor'=>'#4434D8', 'style'=>'color:#FFFFFF'))
             ->setAlternatingItemAttributes(array('bgcolor'=>'#E8E300'))
             ->setFooterAttributes(array('bgcolor'=>'#4434D8', 'style'=>'color:#FFFFFF'));

        $literalColumn = new Zend_DataGrid_Column_Literal('literal');
        $grid->addColumn($literalColumn);

        $this->view->grid = $grid;
    }


    private function getDatasource()
    {
        return $datasource = array(
            array('col1' => 'Test 24', 'col2' => 'valcol11', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'Folie Foli', 'col2' => 'tetet', 	'col3' => 'ploio', 	 'col4' => 'volieze'),
            array('col1' => 'Best grid', 'col2' => 'valcol21', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'Last Value', 'col2' => 'valcol31', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'Do them', 'col2' => 'valcol41', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'All people', 'col2' => 'valcol51', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'Right', 'col2' => 'valcol61', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'Oha', 'col2' => 'valcol71', 'col3' => 'valcol1', 'col4' => 'valcol1'),
            array('col1' => 'Hi', 'col2' => 'valcol81', 'col3' => 'valcol1', 'col4' => 'valcol1'),
        );
    }

}
